
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include "hdf_map.h"

typedef struct Student{
	char sid[19];//身份证号
	char name[50];//姓名
	int age;//年龄
	
}Student;

void test_map(Map *map)
{
	Student s1 = { "372522197102261491","lucy",20 };
  Student s2 = { "37252219710226149x","lily",21 };
  Student s3 = { "210403198411272729","tom",22 };
	
	int32_t result = MapSet(map, s1.sid, &s1, sizeof(Student));
	printf("result = %d\n",result);
	
	MapSet(map, s2.sid, &s2, sizeof(Student));
	MapSet(map, s3.sid, &s3, sizeof(Student));
	
}

void test_MapGet(Map *map,const char *key)
{
	Student *s = (Student*)MapGet(map,key);
	printf("name: %s   age: %d   sid: %s\n",s->name,s->age,s->sid);
}

int main()
{
	Map map;
	//初始化
	MapInit(&map);
	//往哈希表插入节点
  test_map(&map);
	
	printf("nodeSie = %d\n",map.nodeSize);
	
	//从哈希表中取出一个节点
	const char *key = "372522197102261491";
	test_MapGet(&map,key);
	
  //删除整个哈希表
  MapDelete(&map);
  return 0;
}
